package com.jt.controller;/**
 * @Author 金帮嘉诚 @Date 2021-07-30 星期五 16:01
 */

/*本类用于测试*/

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 知识点
 */
@RestController
@CrossOrigin
@RequestMapping("/VueAxios/")
public class AxiosVueController {
    @Autowired
    private UserService userService;

    @GetMapping("user")
    public List<User> getUserList(){
        return userService.getAll();
    }
    @PutMapping("user/{id}/{name}/{age}/{sex}")
    public int update(User user){
        return userService.update(user);
    }

    @DeleteMapping("user/{id}")
    public int delete(User user){
        return userService.delete(user.getId());
    }
    @PostMapping("user/{name}/{age}/{sex}")
    public int add(User user){
        return userService.add(user);
    }

}
